<?php
require_once("xforms/Trigger.php");

class XForms_submit extends XForms_trigger {
  protected $tpl = '<div class="xforms_submit">{renderAppearance} </div>';
  protected $script = '.append(new XForms_submit({renderJson},{renderSubmission}))';
  function renderSubmission(){
    //8.1.9
    $submission = $this->node->getAttribute("submission");
    if($submission) {
      $submission = $this->evalAttribute("submission");
    } else {
      $submission = $this->getModel()
                         ->getElementsByTagNameNS ("http://www.w3.org/2002/xforms", "submission")
                         ->item(0);
    }
    if($submission) {
      $id = $submission->getAttribute("id");
      if(!$id) $id = $this->xforms_processor->getXPath($submission);
    } else {
      $id = null;
    }
    return json_encode($id);
  }
}
